package pack1014;

import java.util.Hashtable;
import java.util.Scanner;
import java.util.concurrent.CopyOnWriteArrayList;

public class App {

    // 类名称 对象名 = new 类名称();
    private static void a() {
        // 其实就是在创建变量，产生出来的对象就是一个值，将值赋予声明的变量p
        // 产生了一个Person类的对象 起了一个名字：p 类型是Person
        Person p = new Person();
        Person p2 = new Person();
        int a = 9;
        String[] array = {"aa", "bb", "cc"};
        System.out.println(a);
        System.out.println(p);
        System.out.println(p2);
        System.out.println(array);
    }

    // 对象创建出来了，咋用呀
    private static void b() {
        Person p = new Person();
        // 属性
        // 操作属性：赋值和获取值
        p.id = 1;
        p.name = "张三";
        p.gender = '女';
        int i = p.id;
        String name = p.name;
        char gender = p.gender;
        System.out.println("id:" + i + ",name:" + name + ",gender:" + gender);
        // 方法
        p.eat("煎饼果子");
        p.sleep();
        p.add(7, 8);
        int result = p.add2(8, 7); // 定义一个变量接收结果
        System.out.println(result);
    }

    private static void c() {
        // 创建对象
        Calculator calculator = new Calculator();
        // 给属性赋值
        calculator.a = Math.random() * 100 + 1;
        calculator.b = Math.random() * 100 + 1;
        System.out.println("属性值分别是：" + calculator.a + "," + calculator.b);
        // 调用方法进行计算
        double sum = calculator.sum();
        double diff = calculator.differ();
        double multi = calculator.multi();
        double division = calculator.division();
        System.out.println(sum);
        System.out.println(diff);
        System.out.println(multi);
        System.out.println(multi);
        System.out.println(division);
    }

    private static void d() {
        DemoA a = new DemoA();
        //a.b();
        DemoB b = new DemoB();
        //b.a();
        a.c();
    }

    private static void e() {
        DemoA a = new DemoA();
        a.sum();
        System.out.println(a.sum);
        a.jisuanOushuHe(0, 1);
    }

    private static void f() {
        DemoA a = new DemoA();
        a.jiujiu(1, 1);
    }

    private static void g() {
        School school = new School();
        Teacher teacher = new Teacher();
        school.id = 1;
        school.name = "宝鸡文理学院";
        teacher.id = 2;
        teacher.name = "张老师";
        teacher.school = school;
        System.out.println(teacher); // teacher.toString();
    }

    private static void h1() {
        /*
            1. 产生了一个对象
            2. 调用了指定的构造器
         */
        DemoF f = new DemoF();
        System.out.println(f);
    }

    private static void h2() {
        // 个数、类型、顺序
        DemoF f1 = new DemoF("7");
        DemoF f2 = new DemoF();
        DemoF f3 = new DemoF(6);
        DemoF f4 = new DemoF(5, "a");
        DemoF f5 = new DemoF("a", 5);
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(f3);
        System.out.println(f4);
        System.out.println(f5);
    }

    public static void main(String[] args) {
        a();
    }
}